﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VswService_V7.OPC.DB;
using VswService_V7.Utility;

namespace VswService_V7.DataBase.Tables
{
    public partial class MILL_PARAMETER
    {
        #region field

        public static readonly string tableName = "MILL_PARAMETER";
        public static readonly string fd_hfwVeeLength = "HFW_VEE_LENGTH";
        public static readonly string fd_hfwPanelCooling = "HFW_PANEL_COOLING";
        public static readonly string fd_lhtPanelCooling = "LHT_PANEL_COOLING";
        public static readonly string fd_lhtInductorCooling = "LHT_INDUCTOR_COOLING";
        public static readonly string fd_jaPanelCooling = "JA_PANEL_COOLING";
        public static readonly string fd_jaInductorCooling = "JA_INDUCTOR_COOLING";
        public static readonly string fd_speed = "SPEED";
        public static readonly string fd_qt = "QT";
        public static readonly string fd_updateTime = "UPDATE_TIME";

        #endregion

        /// <summary>
        /// insert a non-50ms main line parameter record into MILL_PARAMETER
        /// </summary>
        /// <param name="pa"></param>
        /// <returns></returns>
        public static int InsertMillParameter(MillLineParameter pa)
        {
            try
            {
                string sql = string.Format("insert into {0}" +
                    "({1},{2}," +
                    "{3},{4}," +
                    "{5},{6}," +
                    "{7},{8}," +
                    "{9}) " +
                    "values('{10}','{11}'," +
                    "'{12}','{13}'," +
                    "'{14}','{15}'," +
                    "'{16}','{17}'," +
                    "'{18}')",
                    tableName,
                    fd_hfwVeeLength, fd_hfwPanelCooling,
                    fd_lhtPanelCooling, fd_lhtInductorCooling,
                    fd_jaPanelCooling, fd_jaInductorCooling,
                    fd_speed, fd_qt,
                    fd_updateTime,
                    pa.HFW_VEE_Length, pa.HFW_Panel_Cooling,
                    pa.LHT_Panel_Cooling, pa.LHT_Inductor_Cooling,
                    pa.JA_Panel_Cooling, pa.JA_Inductor_Cooling,
                    pa.LineSpeed, pa.QT,
                    pa.updateTime.ToString(Formats.GetLongFormat()));
                return OracleHelper.Exct_NonQuery(sql);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("InsertMillParameter", ex);
                throw ex;
            }
        }
    }

}
